#pragma once
#include "Mesh.h"

#include "FnSurfaceGlobalParam.h"


class FnPatchGenerator
{

public:
	FnPatchGenerator(Mesh& _mesh);
	~FnPatchGenerator(void);

	const Mesh& mesh() const        { return  mesh_; }
	Mesh& mesh()                    { return  mesh_; }

	bool get_shortest_path(const Mesh::VertexHandle _start_vh, const Mesh::VertexHandle _end_vh, std::vector<Mesh::HalfedgeHandle> &path);
	void map_onto_cube(std::vector<Mesh::VertexHandle> &selected_vertices);
	void map_onto_cube_face(std::vector<Mesh::HalfedgeHandle> &edge_path0, std::vector<Mesh::HalfedgeHandle> &edge_path1, std::vector<Mesh::HalfedgeHandle> &edge_path2, std::vector<Mesh::HalfedgeHandle> &edge_path3, int _whichface);
	void set_face_side_info();
	void read_face_side_info(const std::string& _filename);
	void set_cube_face();
	void update_patches();
	void debug_corner_vertices() { map_onto_cube(corner_vertices_); }
	void init_parameterization();
	void parameterization();
	bool export_tag(const std::string &strFilename);
	void setNSides(int n){ nSides = n;}

private:
	 Mesh&       mesh_;
	 OpenMesh::FPropHandleT<int> fprop_cube_face_;
	 OpenMesh::VPropHandleT<int> vprop_cube_face_;
	 OpenMesh::EPropHandleT<bool> eprop_cube_edge_flag_;
	 std::vector<Mesh::VertexHandle> corner_vertices_;
	 FnSurfaceGlobalParam fnParam_;
	 int nSides;
};
